package simportal.persistent;

import java.util.ArrayList;
import java.util.List;

import com.cfuture08.eweb4j.orm.config.annotation.Column;
import com.cfuture08.eweb4j.orm.config.annotation.Id;
import com.cfuture08.eweb4j.orm.config.annotation.ManyMany;
import com.cfuture08.eweb4j.orm.config.annotation.One;
import com.cfuture08.eweb4j.orm.config.annotation.Table;
import com.cfuture08.util.JsonConverter;

/**
 * 权限-持久化对象
 * 
 * @author weiwei[l.weiwei@163.com]
 * 
 */
@Table("t_Permission")
public class Permission {
	@Id
	@Column("")
	private Integer id;// 自增长ID
	private String name;// 权限名称
	@Column("")
	private String url;// http访问url
	@Column("")
	private String description;// 描述
	//权限和操作时多对一的关系，一种操作可以形成多种权限（搭配不同的url）
	//暂时来说操作目前有GET、POST、PUT、DELETE四种操作，不排除未来会有其他操作
	@One(column = "operationId")
	private Operation operation;// 操作
	// 角色权限是多对多关系
	@ManyMany(target = Role.class, relTable = "t_Role_Permission", from = "permissionId", to = "roleId")
	private List<Role> roles = new ArrayList<Role>();// 角色

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Operation getOperation() {
		return operation;
	}

	public void setOperation(Operation operation) {
		this.operation = operation;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public String toString() {
		return JsonConverter.convert(this);
	}
}
